package com.plian.system.controller.wf;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.plian.Tools.*;
import com.plian.Tools.pagedata.PageData;
import com.plian.system.bean.wf.TaskWithForm;
import com.plian.system.bean.wf.UserPOJO;
import com.plian.system.bean.wf.UserTaskPOJO;
import com.plian.system.common.status.CustomCode;
import com.plian.system.config.Resubmit;
import com.plian.system.config.exception.MyRuntimeException;
import com.plian.system.constant.sys.FormStatusConstant;
import com.plian.system.constant.sys.FormTypeConstant;
import com.plian.system.constant.wf.TaskStateConstant;
import com.plian.system.dao.sys.per.UserOrgDao;
import com.plian.system.entity.pm.annualdonationrecord.AnnualDonationRecord;
import com.plian.system.entity.pm.annualdonationrecordmain.AnnualDonationRecordMain;
import com.plian.system.helper.wf.WorkFlowHelper;
import com.plian.system.model.CommonCode;
import com.plian.system.model.ListResult;
import com.plian.system.model.ObjResult;
import com.plian.system.model.R;
import com.plian.system.mybatis.support.Condition;
import com.plian.system.service.mt.todo.TodoService;
import com.plian.system.service.pm.annualdonationexecutemain.IAnnualDonationExecuteMainService;
import com.plian.system.service.pm.annualdonationrecord.IAnnualDonationRecordService;
import com.plian.system.service.pm.annualdonationrecordmain.IAnnualDonationRecordMainService;
import com.plian.system.service.sys.user.UserService;
import com.plian.system.service.wf.FormPrivilegeService;
import com.plian.system.service.wf.WorkFlowFormService;
import com.plian.system.service.wf.WorkflowService;
import com.plian.system.vo.pm.annualdonationrecord.AnnualDonationRecordVO;
import com.plian.system.vo.pm.annualdonationrecordmain.AnnualDonationRecordMainVO;
import com.plian.system.wrapper.pm.annualdonationrecordmain.AnnualDonationRecordMainWrapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.task.api.Task;
import org.flowable.task.service.impl.persistence.entity.TaskEntity;
import org.flowable.task.service.impl.persistence.entity.TaskEntityImpl;
import org.flowable.ui.modeler.domain.ApprovalPoints;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;

import static com.plian.system.constant.sys.FormTypeConstant.*;
import static com.plian.system.constant.wf.WorkflowConstant.*;

@SuppressWarnings("Duplicates")
@Slf4j
@RestController
@RequestMapping("api/work-flow/")
public class WorkflowController {
    @Autowired
    private WorkflowService workFlowService;

    @Autowired
    private WorkFlowFormService workFlowFormService;

    @Autowired
    private FormPrivilegeService formPrivilegeService;

    @Autowired(required = false)
    private RuntimeService runtimeService;

    @Autowired(required = false)
    private TaskService taskService;

    @Autowired
    private WorkFlowHelper workFlowHelper;

    @Autowired
    private UserService userService;

    @Autowired
    private TodoService todoService;

    @Autowired
    private UserOrgDao userOrgDao;

    @Autowired
    private IAnnualDonationRecordService annualDonationRecordService;
    @Autowired
    private IAnnualDonationRecordMainService annualDonationRecordMainService;
    @Autowired
    private IAnnualDonationExecuteMainService annualDonationExecuteMainService;

    @Transactional
    @PostMapping(value = "submit")
    @Resubmit(delaySeconds = 0)
    public ObjResult submit(@RequestBody PageData pd) {
        try {
            if (pd.get("assignUserIdList") != null && CollectionUtil.isNotEmpty((List<String>) pd.get("assignUserIdList"))) {
                return assignBegin(pd);
            }
            String formId = pd.getString(FORM_ID_KEY);
            int formType = pd.getInteger(FORM_TYPE);
            HashMap<String, Object> workflowVariables;

            workFlowService.clearOldUnWorkFlow(formType,formId);

            if (Tools.notEmpty(pd.getString("code"))) {
                String code = pd.getString("code");
                try {
                    workflowVariables = workFlowFormService.submit(formType, formId, code);
                }catch (Exception e){
                    log.error(ExceptionUtils.getFullStackTrace(e));
                    return new ObjResult(e.getMessage());
                }
            } else {
                workflowVariables = workFlowFormService.submit(formType, formId);
                if(formType == FormTypeConstant.JLR_STAFF_FORM && workflowVariables.containsKey("jlrError")){
                    return new ObjResult((String) workflowVariables.get("jlrError"));
                }
                if(formType == FormTypeConstant.ZCGLR_STAFF_FORM && workflowVariables.containsKey("zcglError")){
                    return new ObjResult((String) workflowVariables.get("zcglError"));
                }
            }
            if(formType== FormTypeConstant.PM_ANNUALDONATIONRECORD_FORM){//企业捐赠计划备案特殊处理

                /*HashMap<String,AnnualDonationRecord> map=new HashMap<>();
                List<AnnualDonationRecord> records=annualDonationRecordService.list(new LambdaQueryWrapper<AnnualDonationRecord>()
                        .eq(AnnualDonationRecord::getParentId, formId));

                BigDecimal amount=new BigDecimal(0);
                if(records!=null&&records.size()>0){
                    for (AnnualDonationRecord record: records) {
                        if(record!=null&&record.getDonationAmount()!=null){
                            amount=amount.add(record.getDonationAmount());
                        }
                    }
                }
                workflowVariables.put("juanzengjine",amount.multiply(new BigDecimal(10000)));*/
                if(annualDonationRecordMainService.checkJzjh(Long.parseLong(formId))){//为了不改流程图就判断为true就复制50000以上
                    workflowVariables.put("juanzengjine",500000);
                }else{
                    workflowVariables.put("juanzengjine",0);
                }
            }
            if(formType == FormTypeConstant.PM_ANNUALDONATIONEXECUTE_FORM){//企业捐赠计划执行备案特殊处理
                if(annualDonationExecuteMainService.checkJzjh(Long.parseLong(formId))){//为了不改流程图就判断为true就复制50000以上
                    workflowVariables.put("juanzengjine",500000);
                }else{
                    workflowVariables.put("juanzengjine",0);
                }
            }
            workFlowService.submit(formId, formType, workflowVariables);
            if (workFlowService.isFinish(formId)) {
                workFlowFormService.finish(formType, formId);
            }
        } catch (MyRuntimeException e) {
            log.error(ExceptionUtils.getFullStackTrace(e));
            throw e;
        } catch (Exception e) {
            log.error(ExceptionUtils.getFullStackTrace(e));
            return new ObjResult(CommonCode.ERROR);
        }
        return new ObjResult(CommonCode.SUCCESS);
    }

    /**
     * 待办列表
     */
    @PostMapping(value = "todo-task-list")
    public ListResult<TaskWithForm> todoTaskList(@RequestBody PageData pd) throws Exception {
        String userId = TokenUtil.getTokenUserId();
        PageData pageData = new PageData();
        pageData.put("id", userId);
        PageData user = userService.findbyid(pageData).getPageData();
        String organizationId;
        if (user.getInteger("type") == 1 || user.getInteger("type") == 2) {
            List<PageData> list = userOrgDao.queryUserOrg(userId);
            if (list.size() != 1) {
                throw new MyRuntimeException(new ObjResult("当前登录用户属于国资委，未配置单位或者配置多个单位，请联系管理员！"));
            }
            organizationId = list.get(0).getString("orgId");
        } else {
            organizationId = TokenUtil.getTokenOrgId();
        }
        List<TaskWithForm> taskList = workFlowService.getTodoTaskListByUserId(userId, organizationId);
        //todo  手动分页？
        ListResult<TaskWithForm> result = new ListResult<>(CommonCode.SUCCESS);
        List<Integer> formTypes = (List<Integer>)pd.get("formTypes");
        if (CollectionUtil.isNotEmpty(formTypes)){
            taskList = taskList.stream().filter(taskWithForm -> formTypes.contains(Integer.valueOf(taskWithForm.getFormType())))
                    .collect(Collectors.toList());
        }
        result.setTotal(CollectionUtil.isNotEmpty(taskList) ? taskList.size() : 0);
        taskList = workFlowService.listPage(taskList, pd);
//        workFlowFormService.fillFormData(taskList);
        result.setList(taskList);
        return result;
    }

    /**
     * 待办列表
     */
    @GetMapping(value = "todo-task-queryType")
    public ListResult<Integer> todoTaskQueryType() throws Exception {
        String userId = TokenUtil.getTokenUserId();
        PageData pageData = new PageData();
        pageData.put("id", userId);
        PageData user = userService.findbyid(pageData).getPageData();
        String organizationId;
        if (user.getInteger("type") == 1 || user.getInteger("type") == 2) {
            List<PageData> list = userOrgDao.queryUserOrg(userId);
            if (list.size() != 1) {
                throw new MyRuntimeException(new ObjResult("当前登录用户属于国资委，未配置单位或者配置多个单位，请联系管理员！"));
            }
            organizationId = list.get(0).getString("orgId");
        } else {
            organizationId = TokenUtil.getTokenOrgId();
        }
        List<TaskWithForm> taskList = workFlowService.getTodoTaskListByUserId(userId, organizationId);
        List<Integer> fomTypes = taskList.stream().map(TaskWithForm::getFormType)
                .collect(Collectors.toSet()).stream().collect(Collectors.toList());
        fomTypes.sort((a, b) -> a-b);
        ListResult<Integer> result = new ListResult<>(CommonCode.SUCCESS);
        result.setList(fomTypes);
        return result;
    }

    /**
     * 当前用户审批过的task列表
     */
    @RequestMapping("completed-task-list")
    public ListResult<PageData> completedTaskList(@RequestBody PageData pd) {
        pd.put("assigneeId", TokenUtil.getTokenUserId());
        pd.put("assigneeOrganizationId", TokenUtil.getTokenOrgId());
        return workFlowService.getCompletedTasksByCurrentUserInPage(pd);
    }

    /**
     * 获取所有已办单据类型
     * @return
     * @throws Exception
     */
    @GetMapping(value = "completed-task-queryType")
    public ListResult<Integer> completedTaskQueryType() throws Exception {
        PageData pageData = new PageData();
        pageData.put("assigneeId", TokenUtil.getTokenUserId());
        pageData.put("assigneeOrganizationId", TokenUtil.getTokenOrgId());
        ListResult<Integer> result = new ListResult<>(CommonCode.SUCCESS);
        result.setList(workFlowService.getFormTypes(pageData));
        return result;
    }

    @Transactional
    @PostMapping(value = "complete-task")
    public ObjResult completeTask(@RequestBody PageData pd) {
        if (pd.get("assignUserIdList") != null && CollectionUtil.isNotEmpty((List<String>) pd.get("assignUserIdList"))) {
            return assignComplete(pd);
        }
        List<Integer> privilegeCodeList = (List<Integer>) pd.get("list");
        String formId = pd.getString(FORM_ID_KEY);
        int formType = pd.getInteger(FORM_TYPE);
        String comment = pd.getString(COMMENT_KEY);
        try {
            HashMap<String, Object> variables = new HashMap<>();
            variables.put("isBeforeSignReject", pd.getString("isBeforeSignReject"));
            workFlowService.completeTask(formId, comment, variables);
            formPrivilegeService.privilege(formType, formId, privilegeCodeList, pd);
        } catch (Exception e) {
            log.error(ExceptionUtils.getFullStackTrace(e));
            return new ObjResult(CommonCode.ERROR);
        }
        if (workFlowService.isFinish(formId)) {
            workFlowFormService.finish(formType, formId);
        }
        return new ObjResult(CommonCode.SUCCESS);
    }

    /**
     * 主动撤回
     */
    @Transactional
    @PostMapping(value = "roll-back")
    public ObjResult rollBack(@RequestBody PageData pd) {
        String formId = pd.getString(FORM_ID_KEY);
        workFlowService.rollBack(formId);
        return new ObjResult(CommonCode.SUCCESS);
    }

    /**
     * 主动撤回
     */
    @Transactional
    @PostMapping(value = "roll-back-before-sign")
    public ObjResult rollBackBeforeSign(@RequestBody PageData pd) {
        String formId = pd.getString(FORM_ID_KEY);
        workFlowService.rollBackBeforeSign(formId);
        return new ObjResult(CommonCode.SUCCESS);
    }

    @PostMapping(value = "turn-back")
    @Transactional
    public ObjResult turnBack(@RequestBody PageData pd) throws Exception {
        String comment = pd.getString(COMMENT_KEY);
        List<ApprovalPoints> approvalPointsList = (List<ApprovalPoints>) pd.get(APPROVAL_POINTS_LIST_KEY);
        String formId = pd.getString(FORM_ID_KEY);
        workFlowService.turnBack(formId, comment, approvalPointsList);
        return new ObjResult(CommonCode.SUCCESS);
    }

    @Transactional
    @PostMapping(value = "refuse-task")
    public ObjResult refuseTask(@RequestBody PageData pd) {
        try {
            String formId = pd.getString(FORM_ID_KEY);
            int formType = pd.getInteger(FORM_TYPE);
            String comment = pd.getString(COMMENT_KEY);
            List<ApprovalPoints> approvalPointsList = (List<ApprovalPoints>) pd.get(APPROVAL_POINTS_LIST_KEY);
            workFlowService.returnFirst(formId, comment, approvalPointsList);
            workFlowFormService.reject(formType, formId, FormStatusConstant.REJECT, comment);
        } catch (Exception e) {
            log.error(ExceptionUtils.getFullStackTrace(e));
            return new ObjResult(CommonCode.ERROR);
        }
        return new ObjResult(CommonCode.SUCCESS);
    }

    @PostMapping(value = "get-by-form-id")
    public ObjResult getByFormId(@RequestBody PageData pd) {
        String formId = pd.getString(FORM_ID_KEY);
        ObjResult result = new ObjResult(CommonCode.SUCCESS);
        PageData pageData = new PageData();
        pageData.put("taskInfo", workFlowService.getTaskInfoByFormId(formId));
        result.setPageData(pageData);
        return result;
    }

    @PostMapping("before-add-sign")
    @Transactional
    public ObjResult beforeAddSign(@RequestBody PageData pd) {
        String formId = pd.getString("formId");
        String userId = pd.getString("userId");
        String signedUserId = pd.getString("signedUserId");
        workFlowService.beforeAddSign(formId, userId, signedUserId);
        return new ObjResult(CommonCode.SUCCESS);
    }

    @PostMapping("assign-finish")
    @Transactional
    public ObjResult assignFinish(@RequestBody PageData pd) {
        String formId = pd.getString("formId");
        String comment = pd.getString("comment");
        ProcessInstance processInstance = runtimeService
                .createProcessInstanceQuery()
                .processInstanceBusinessKey(formId)
                .singleResult();
        List<Task> taskList = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();
        if (taskList.size() != 1) {
            throw new MyRuntimeException(new ObjResult("任务不唯一"));
        }

        TaskEntity taskEntity = (TaskEntityImpl) taskList.get(0);
        List<UserTaskPOJO> userTaskList = workFlowHelper.getUserTaskListInProcessVariable(runtimeService.getVariable(taskEntity.getProcessInstanceId(), USER_TASK_INFO_KEY));
        UserTaskPOJO last = userTaskList.get(userTaskList.size() - 1);
        last.setComment(comment);
        last.setFinishTime(new Date());
        last.setTaskState(TaskStateConstant.STATE_AGREE);
        todoService.fallback(pd);
        taskService.addComment(taskEntity.getId(), taskEntity.getProcessInstanceId(), comment);
        taskService.complete(taskEntity.getId());
        taskService.complete(taskEntity.getParentTaskId());
        return new ObjResult(CommonCode.SUCCESS);
    }

    public ObjResult assignBegin(PageData pd) throws Exception {
        String formId = pd.getString("formId");
        int formType = pd.getInteger("formType");
        List<String> assignUserIdList = (List<String>) pd.get("assignUserIdList");
        workFlowService.startProcessInstanceByKeyAndTenantId(formId, formType, new HashMap<>(), TokenUtil.getTokenUserId());
        ProcessInstance processInstance = runtimeService
                .createProcessInstanceQuery()
                .processInstanceBusinessKey(formId)
                .singleResult();
        List<Task> taskList = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();
        if (taskList.size() != 1) {
            throw new MyRuntimeException(new ObjResult("起始任务不唯一"));
        }
        Task task = taskList.get(0);
        List<UserTaskPOJO> userTaskPOJOS = new ArrayList<>();
        UserPOJO userPOJO = new UserPOJO(userService.getCurrentUser());
        UserTaskPOJO userTaskPOJO = new UserTaskPOJO();
        userTaskPOJO.setUserPOJO(userPOJO);
        userTaskPOJO.setTaskDefineId(task.getTaskDefinitionKey());
        userTaskPOJO.setTaskName(task.getName());
        userTaskPOJO.setTaskState(TaskStateConstant.STATE_APPLIED);
        userTaskPOJO.setFinishTime(new Date());
        userTaskPOJO.setTaskId(task.getId());
        userTaskPOJOS.add(userTaskPOJO);
        TaskEntityImpl taskEntity = (TaskEntityImpl) task;
        taskEntity.setAssignee(null);
        taskEntity.setCountEnabled(true);
        taskEntity.setScopeType("assign-begin");
        taskService.saveTask(taskEntity);

        if (CollectionUtil.isNotEmpty(assignUserIdList)) {
            for (String assignUserId : assignUserIdList) {
                TaskEntity newTask = (TaskEntity) taskService.newTask(UuidUtil.get32UUID());
                newTask.setTenantId(taskEntity.getTenantId());
                newTask.setAssignee(assignUserId);
                newTask.setName("下发审核");
                newTask.setParentTaskId(taskEntity.getId());
                newTask.setProcessDefinitionId(taskEntity.getProcessDefinitionId());
                newTask.setProcessInstanceId(taskEntity.getProcessInstanceId());
                newTask.setTaskDefinitionKey(taskEntity.getTaskDefinitionKey());
                newTask.setTaskDefinitionId(taskEntity.getTaskDefinitionId());
                newTask.setCreateTime(new Date());
                newTask.setScopeType("assign-son");
                taskService.saveTask(newTask);
            }
        }

        UserTaskPOJO userTaskPOJO1 = new UserTaskPOJO();
        if (CollectionUtil.isNotEmpty(assignUserIdList)) {
            for (String assignUserId : assignUserIdList) {
                PageData pageData = new PageData();
                pageData.put("id", assignUserId);
                PageData pageData1 = userService.findbyid(pageData).getPageData();
                UserPOJO userPOJO1 = new UserPOJO(pageData1);
                userTaskPOJO1.setUserPOJO(userPOJO1);
            }
        }
        //userTaskPOJO1.setTaskDefineId(newTask.getTaskDefinitionKey());
        userTaskPOJO1.setTaskName("下发审核");
        userTaskPOJO1.setTaskState(TaskStateConstant.STATE_TODO);
        userTaskPOJOS.add(userTaskPOJO1);
        workFlowHelper.saveUserTaskListIntoVariable(userTaskPOJOS, processInstance.getId());
        //try {
        //    workFlowFormService.submit(formType, formId);
        //} catch (Exception e) {
        //    log.error(ExceptionUtils.getFullStackTrace(e));
        //}
        return new ObjResult(CommonCode.SUCCESS);
    }

    private ObjResult assignComplete(PageData pd) {
        String formId = pd.getString(FORM_ID_KEY);
        String comment = pd.getString(COMMENT_KEY);
        List<String> assignUserIdList = (List<String>) pd.get("assignUserIdList");
        ProcessInstance processInstance = runtimeService
                .createProcessInstanceQuery()
                .processInstanceBusinessKey(formId)
                .singleResult();
        List<Task> taskList = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();

        TaskEntity taskEntity = (TaskEntityImpl) taskList.get(0);
        if (CollectionUtil.isNotEmpty(assignUserIdList)) {
            for (String assignUserId : assignUserIdList) {
                TaskEntity newTask = (TaskEntity) taskService.newTask(UuidUtil.get32UUID());
                newTask.setTenantId(taskEntity.getTenantId());
                newTask.setAssignee(assignUserId);
                newTask.setName("下发审核");
                newTask.setParentTaskId(taskEntity.getParentTaskId());
                newTask.setProcessDefinitionId(taskEntity.getProcessDefinitionId());
                newTask.setProcessInstanceId(taskEntity.getProcessInstanceId());
                newTask.setTaskDefinitionKey(taskEntity.getTaskDefinitionKey());
                newTask.setTaskDefinitionId(taskEntity.getTaskDefinitionId());
                newTask.setCreateTime(new Date());
                newTask.setScopeType("assign-son");
                taskService.saveTask(newTask);
            }
        }

        taskService.addComment(taskEntity.getId(), taskEntity.getProcessInstanceId(), comment);
        for (Task task : taskList) {
            taskService.complete(task.getId());
        }

        List<UserTaskPOJO> userTaskList = workFlowHelper.getUserTaskListInProcessVariable(runtimeService.getVariable(taskEntity.getProcessInstanceId(), USER_TASK_INFO_KEY));
        UserTaskPOJO last = userTaskList.get(userTaskList.size() - 1);
        last.setComment(comment);
        last.setFinishTime(new Date());
        last.setTaskState(TaskStateConstant.STATE_AGREE);

        UserTaskPOJO userTaskPOJO = new UserTaskPOJO();
        if (CollectionUtil.isNotEmpty(assignUserIdList)) {
            for (String assignUserId : assignUserIdList) {
                PageData pageData = new PageData();
                pageData.put("id", assignUserId);
                PageData pageData1 = userService.findbyid(pageData).getPageData();
                UserPOJO userPOJO1 = new UserPOJO(pageData1);
                userTaskPOJO.setUserPOJO(userPOJO1);
            }
        }
        //userTaskPOJO.setTaskDefineId(newTask.getTaskDefinitionKey());
        userTaskPOJO.setTaskName("下发审核");
        userTaskPOJO.setTaskState(TaskStateConstant.STATE_TODO);
        userTaskList.add(userTaskPOJO);
        workFlowHelper.saveUserTaskListIntoVariable(userTaskList, processInstance.getId());
        return new ObjResult(CommonCode.SUCCESS);
    }

    //@Transactional
    //@PostMapping(value = "before-sign-reject")
    //public ObjResult beforeSignReject(@RequestBody PageData pd) {
    //    String formId = pd.getString(FORM_ID_KEY);
    //    String comment = pd.getString(COMMENT_KEY);
    //    workFlowService.completeTask(formId, comment, null);
    //    return new ObjResult(CommonCode.SUCCESS);
    //}

    @Transactional
    @PostMapping("go-back-to-stash")
    public ObjResult goBackToStash(@RequestBody PageData pd) {
        String formId = pd.getString("formId");
        int formType = pd.getInteger("formType");
        if (formType == PM_PROPERTY_FORM || formType == PM_PROPERTYCHANGE_FORM || formType == PM_PROPERTYOUT_FORM){
            return new ObjResult(CustomCode.builder().message("该单据类型不支持反审核").code(1999).success(false).build());
        }
        workFlowFormService.goBackToStash(formType, formId);
        workFlowService.goBackToStash(formId, formType);
        return new ObjResult(CommonCode.SUCCESS);
    }

    /**
     * 没有流程的单据回退
     * @param pd
     * @return
     */
    @Transactional
    @PostMapping("back-to-stash")
    public ObjResult BackToStash(@RequestBody PageData pd) {
        String formId = pd.getString("formId");
        int formType = pd.getInteger("formType");
        workFlowFormService.goBackToStash(formType, formId);
        if(103 == formType){
            workFlowService.goBackToStash(formId, formType);
        }
        return new ObjResult(CommonCode.SUCCESS);
    }

    @Transactional
    @PostMapping("/deleteUnknowReceipts")
    public ObjResult deleteUnknowReceipts(){
        workFlowService.deleteUnknowReceipts();
        return new ObjResult(CommonCode.SUCCESS);
    }

    @Transactional
    @PostMapping("/update-variables-all-info")
    public ObjResult updateVariablesAllInfo(){
        workFlowService.updateVariablesAllInfo();
        return new ObjResult(CommonCode.SUCCESS);
    }

}
